#!/usr/bin/env node

const Dog = require('./05-dog.js');

const taidi = new Dog('tadi',3),
  zangao = new Dog('zangao',6);
taidi.on('bark',onBark.bind(taidi));
zangao.on('bark',onBark.bind(zangao));

function onBark(){
  console.log(`name: ${this.name}energy:${this.energy}`);
}
setTimeout(()=>{
  console.log('taidi eat food');
  taidi.setEnergy(3);
},10000);

